import pandas as pd
import rule_engine

if __name__ == '__main__':

    # 创建示例 DataFrame
    data = {
        'id': [1, 2, 3, 4],
        'ts': [
            pd.Timestamp('2023-01-01'),
            None,
            pd.NaT,  # pandas 的时间空值
            pd.Timestamp('2023-01-04')
        ]
    }
    df = pd.DataFrame(data)

    # 创建规则：检查时间字段非空
    rule = rule_engine.Rule('empty(ts)')

    for index, row in df.iterrows():
        res = rule.matches(row[['ts']])
        print(res)